# -*- coding:utf-8 -*-
from bs4 import BeautifulSoup
import datetime
data='''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <base href="asdf" />    
    <title>Beautiful Soup Documentation &mdash; Beautiful Soup 4.0.0 documentation</title>
    
    <link id="23" rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <a id="asdf" class='111'>中文sd□afdsfdsfdsf</a>
    <a id='asdf1'>sdafdsfdsfdsf</a>
    <a id='asdf2'>sdafdsfdsfdsf</a>
    </head>
    '''
data=data
#print data.decode('utf-8')
#data=open('d:/tmp/1.html').read()
#data=data.decode('gbk')
start_time=datetime.datetime.now()
soup=BeautifulSoup(str(data),'lxml',from_encoding="utf-8")
end_time=datetime.datetime.now()

#data=soup.prettify('gbk')
#print data.decode('gbk')
##print end_time-start_time
###print soup.find_all('div')[1].clear()
##
##data=soup.meta.get('content')
##print data
##print soup.title.get_text()
##soup.find('a')['href']='link'
##data=soup.find_all('a',href=True)
##for a in data:
##    print a.get('href','############################3')
###print str(soup)
##
##print soup.find('a',{'class':'111'})

print soup.find_all('base')#[0].decompose()

print soup.prettify()






